import { useLocation, Navigate } from 'react-router-dom'
import { getCookie } from '../utils'
const whileList = ['/login', '/sigin']

const BeforeEach = (props: any) => {
    const location = useLocation()
    if (!getCookie() && !whileList.includes(location.pathname)) {
        return <Navigate to={'/login'}></Navigate>
    }
    return props.children
}

export default BeforeEach